package cn.hsw.platform.core.util;

import cn.hsw.platform.core.base.BaseConstant;

import java.util.regex.Matcher;

/**
 * 字符串工具
 * @author 李子木
 * @date 2020-11-02
 */
public class StrUtil extends cn.hutool.core.util.StrUtil {



    /**
     * 把_转换成驼峰
     * @param value 要转换的下划线字符串
     * @return 驼峰体字符串
     */
    public static String underLineToCamel(final String value) {
        StringBuffer sb = new StringBuffer();
        Matcher matcher = BaseConstant.UNDER_LINE_PATTERN.matcher(value);
        while (matcher.find()){
            matcher.appendReplacement(sb,matcher.group(1).toUpperCase());
        }
        matcher.appendTail(sb);
        return sb.toString();
    }


    public static String objToString(Object obj){
        if(Validator.isEmpty(obj)){
            return "";
        }else{
            return obj.toString();
        }
    }
}
